package day07;

import java.util.Arrays;
import java.util.Scanner;

public class CalTotalAvg {
    public static void main(String[] args) {
        double[] scores = EnterDate();
        double total = Totalscores(scores);
        System.out.println("总分为"+total+"分");
        double avg = Avgscores(scores);
        System.out.println("平均分为"+avg+"分");
    }



    public static double[] EnterDate() {
        Scanner scan = new Scanner(System.in);
        double[] scores = new double[6];
        for (int i = 0; i < scores.length; i++) {
            System.out.println("请输入第" + (i + 1) + "个评委的成绩");
            scores[i] = scan.nextDouble();
        }
        return scores;
    }

    public static double Totalscores(double[] scores){

        double Total = 0.0;
        for (int i = 0; i < scores.length; i++){
            Total += scores[i];
        }

        return Total;
    }

    public static double Avgscores(double[] scores){
        double Total = 0.0;
        Arrays.sort(scores);
        for (int i = 1; i < scores.length-1; i++){
            Total += scores[i];
        }
        double avg = Total/(scores.length-2);

        return avg;
    }
}
